﻿package mortal.game.view.autoArena.view
{
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.view.autoArena.renderer.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;

    public class AutoArenaMyRecordWin extends BaseWindow
    {
        private var _rankList:GTileList;
        private static var _instance:AutoArenaMyRecordWin;

        public function AutoArenaMyRecordWin()
        {
            setSize(682 - 20 - 3, 459 - 7 + 68 + 5 - 10);
            title = Language.getString(41499);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.pushUIToDisposeVec(UIFactory.bg(8, 41, 668 - 20, 410 + 68 + 5 - 10, this));
            this._rankList = UIFactory.tileList(10, 65 - 10, 668 - 20, 457, this);
            this._rankList.columnWidth = 668 - 20;
            this._rankList.rowHeight = 43;
            this._rankList.horizontalGap = 0;
            this._rankList.verticalGap = 0;
            this._rankList.setStyle("skin", new Bitmap());
            this._rankList.setStyle("cellRenderer", AutoArenaRecordListRenderer);
            this.reqRecordInfo();
            this.addListeners();
            return;
        }// end function

        private function reqRecordInfo() : void
        {
            GameProxy.autoArena.getMyRecord();
            return;
        }// end function

        private function addListeners() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.AutoArenaGetMyRecord, this.onGetMyRecordHandler);
            return;
        }// end function

        private function removeListeners() : void
        {
            NetDispatcher.removeCmdListener(ServerCommand.AutoArenaGetMyRecord, this.onGetMyRecordHandler);
            return;
        }// end function

        private function onGetMyRecordHandler(param1:Object) : void
        {
            var _loc_2:* = Cache.instance.autoArena.autoArenaRecordArr;
            var _loc_3:* = Math.ceil(_loc_2.length / 10);
            this.updateInfoList();
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            this.updateInfoList();
            return;
        }// end function

        private function updateInfoList() : void
        {
            var _loc_1:* = Cache.instance.autoArena.autoArenaRecordArr;
            var _loc_2:* = _loc_1.slice(0, 10);
            var _loc_3:* = new DataProvider();
            _loc_3.addItems(_loc_2);
            this._rankList.dataProvider = _loc_3;
            this._rankList.drawNow();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._rankList.dispose();
            this._rankList = null;
            this.removeListeners();
            return;
        }// end function

        public static function get instance() : AutoArenaMyRecordWin
        {
            if (_instance == null)
            {
                _instance = new AutoArenaMyRecordWin;
            }
            return _instance;
        }// end function

    }
}
